#ifndef _H_HIREDIS2WRAP_
#define _H_HIREDIS2WRAP_

#if ( defined __linux ) || ( defined __unix )
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#ifndef SNPRINTF
#define VSNPRINTF              vsnprintf
#define SNPRINTF               snprintf
#endif
#ifndef STRCMP
#define STRCMP(_a_,_C_,_b_) ( strcmp(_a_,_b_) _C_ 0 )
#define STRNCMP(_a_,_C_,_b_,_n_) ( strncmp(_a_,_b_,_n_) _C_ 0 )
#define STRICMP(_a_,_C_,_b_) ( strcasecmp(_a_,_b_) _C_ 0 )
#define STRNICMP(_a_,_C_,_b_,_n_) ( strncasecmp(_a_,_b_,_n_) _C_ 0 )
#endif
#elif ( defined _WIN32 )
#include <windows.h>
#ifndef SNPRINTF
#define VSNPRINTF              _vsnprintf
#define SNPRINTF               _snprintf
#endif
#ifndef STRCMP
#define STRICMP(_a_,_C_,_b_) ( stricmp(_a_,_b_) _C_ 0 )
#define STRNICMP(_a_,_C_,_b_,_n_) ( strnicmp(_a_,_b_,_n_) _C_ 0 )
#endif
#endif

#include "hiredis/hiredis.h"

#define MAXLEN_REDISCOMMAND	1024

#define HIREDIS2WRAP_ERROR_OVERFLOW	-11
#define HIREDIS2WRAP_ERROR_ALLOC	-12
#define HIREDIS2WRAP_ERROR_COMMAND	-13

int RedisCommandOK( redisContext *conn , int *ok , char *format , ... );
int RedisCommandInteger( redisContext *conn , int *integer , char *format , ... );
int RedisCommandDouble( redisContext *conn , double *d , char *format , ... );
int RedisCommandString( redisContext *conn , char *buffer , int bufsize , char *format , ... );
int RedisCommandStrdnp( redisContext *conn , char **pptr , char *format , ... );
int RedisCommandStringToInteger( redisContext *conn , int *integer , char *format , ... );
int RedisCommandArray( redisContext *conn , int *p_elements , redisReply **pp_reply , char *format , ... );

int RedisArrayOK( redisReply *reply , int index , int *ok );
int RedisArrayInteger( redisReply *reply , int index , int *integer );
int RedisArrayDouble( redisReply *reply , int index , double *d );
int RedisArrayString( redisReply *reply , int index , char *buffer , int bufsize );
int RedisArrayStrdup( redisReply *reply , int index , char **pptr );
int RedisArrayStringToInteger( redisReply *reply , int index , int *integer );

void RedisFreeArray( redisReply **pp_reply );

int RedisGetError( redisContext *conn );
char *RedisGetErrorString( redisContext *conn );

#endif

